package com.xmu.prcs.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
/**
 * 专题表
 * @author frequent
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "subject", uniqueConstraints = @UniqueConstraint(columnNames = "subjectname"))
public class Subject implements Serializable {

	private Integer idSubject;
	private String subjectName;//专题名
	private String subjectInfo;//专题介绍
	private Date updateTime;//建立时间
	private Set<Plant> plants;//专题下的所有植物
	
	public Subject(){
		
	}
	
	public Subject(String subjectName, String subjectInfo, Date updateTime){
		this.subjectName = subjectName;
		this.subjectInfo = subjectInfo;
		this.updateTime = updateTime;
	}

	@Id
	@GeneratedValue
	@Column(name = "idsubject", unique = true, nullable = true)
	public Integer getIdSubject() {
		return idSubject;
	}

	public void setIdSubject(Integer idSubject) {
		this.idSubject = idSubject;
	}

	@Column(name = "subjectname", length = 10)
	public String getSubjectName() {
		return subjectName;
	}

	public void setSubjectName(String subjectName) {
		this.subjectName = subjectName;
	}

	@Column(name = "subjectinfo", length = 200)
	public String getSubjectInfo() {
		return subjectInfo;
	}

	public void setSubjectInfo(String subjectInfo) {
		this.subjectInfo = subjectInfo;
	}

	@Column(name = "updatetime")
	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@OneToMany(fetch = FetchType.LAZY)
	@JoinColumn(name = "idsubject")
	public Set<Plant> getPlants() {
		return plants;
	}

	public void setPlants(Set<Plant> plants) {
		this.plants = plants;
	}
	
}
